//sysCheck
//系统检查类全放这里
//例如：签出坐席页面的时候，检查某个函数，不在签入页面的时候删除这个函数

var sysCheck = (function(){
	
	function Construct()
	{
	  	this.checkOutOneMenu = {}; 
		this.currentPage     = '';
		this.prevPage        = '';
		this.checkMenuBy     = 'action';
	}
	Construct.prototype.set = function(valName,value){
		                            if(typeof value != 'object')
									{
									  return this;	
									}
									if(typeof this[valName] == 'object')
									{
									  this.setObjectVal(valName,value);
									}else{
									  this[valName] = value;  
									}
									return this;
								 }
	Construct.prototype.run = function(actionName){
		if(!actionName || typeof this.checkOutOneMenu[actionName] == 'undefined')
		{
		  return this;	
		}
		if(typeof this.checkOutOneMenu[actionName]['func'] == 'function')
		{
		  this.checkOutOneMenu[actionName]['func']();
		}
	}
	Construct.prototype.setObjectVal = function(valName,value){
	   	                                  if(typeof this[valName] != 'object' || typeof value != 'object')
										  {
											 return this;  
										  }
	                                      if(typeof this[valName][value[this.checkMenuBy]] == 'undefined')
										  {
											 this[valName][value[this.checkMenuBy]] = value;
										  }else if(typeof this[valName][value[this.checkMenuBy]] == 'object'){
											 for(var x in value)
											 {
												if(x == this.checkMenuBy)
												{
												  continue;	
												}else if(x == 'clearTimeoutId' && !!this[valName][value[this.checkMenuBy]][x]){
												  clearTimeout(this[valName][value[this.checkMenuBy]][x]);
												}
												this[valName][value[this.checkMenuBy]][x] = value[x];
											 }
										  }
										  return this;
									 }
    Construct.prototype.get = function(valName,key,subKey){
		                             if(!subKey)
									 {
										var subKey = 'func'; 
									 }
									 if(typeof this[valName] != 'undefined' && typeof key != 'undefined' && typeof this[valName][key] != 'undefined')
									 {
										return this[valName][key][subKey];
									 }else if(typeof this[valName] != 'undefined' && typeof key != 'undefined'){
										return this[valName][key]; 
									 }else if(typeof this[valName] != 'undefined'){
										return this[valName];
									 }else{
										return undefined; 
									 }
								 }
	Construct.prototype.pageChange = function(queryStr){
		  if(this.currentPage != queryStr)
		  {
		   this.set('prevPage',this.currentPage);
		  }
		  this.set('currentPage',queryStr);
		  this.checkOutChangeMenu();
	}
	Construct.prototype.checkOutChangeMenu = function(){
		 
		 for(var x in this.checkOutOneMenu)
		 {
		   if(typeof this.checkOutOneMenu[x] == 'undefined')
		   {
			 continue;   
		   }
		  // console.log(this.checkOutOneMenu[x]);
		   if(!!this.checkOutOneMenu[x]['clearTimeoutId'])
		   {
			clearTimeout(this.checkOutOneMenu[x]['clearTimeoutId']);   
		   }
		   this.checkOutOneMenu[x] = undefined;
		 }
	}
	return new Construct();
})();